from django.contrib import admin
from .models import User, Movie, Rating
# Register your models here.


@admin.register(User)
class UserAdmin(admin.ModelAdmin):
    list_display = ('username', 'gender', 'occupation', 'last_login')
    search_fields = ['username']
    list_filter = ('occupation', )


@admin.register(Movie)
class MovieAdmin(admin.ModelAdmin):
    list_display = ('title', 'release_date', 'imdb_url')
    search_fields = ['title']
    date_hierarchy = 'release_date'


@admin.register(Rating)
class RatingAdmin(admin.ModelAdmin):
    list_display = ('user_id', 'movie_id', 'rating', 'eval_time')
    search_fields = ('user_id__username', 'movie_id__title')
    fk_fields = ('user_id__username', 'movie_id__title')
    list_filter = ('rating', 'eval_time')


admin.site.site_header = '兜瓣运维信息管理系统'
admin.site.site_title = '兜瓣'


